<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE Trustworthy #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE NoImplicitPrelude #-}</span><span>
</span><span id="line-3"></span><span class="hs-pragma">{-# LANGUAGE GADTs #-}</span><span>
</span><span id="line-4"></span><span class="hs-pragma">{-# LANGUAGE ExplicitForAll #-}</span><span>
</span><span id="line-5"></span><span class="hs-pragma">{-# LANGUAGE PatternSynonyms #-}</span><span>
</span><span id="line-6"></span><span class="hs-pragma">{-# LANGUAGE ScopedTypeVariables #-}</span><span>
</span><span id="line-7"></span><span class="hs-pragma">{-# LANGUAGE TypeApplications #-}</span><span>
</span><span id="line-8"></span><span>
</span><span id="line-9"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- Module      :  Data.Dynamic</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- Copyright   :  (c) The University of Glasgow 2001</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- License     :  BSD-style (see the file libraries/base/LICENSE)</span><span>
</span><span id="line-14"></span><span class="hs-comment">--</span><span>
</span><span id="line-15"></span><span class="hs-comment">-- Maintainer  :  libraries@haskell.org</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- Stability   :  experimental</span><span>
</span><span id="line-17"></span><span class="hs-comment">-- Portability :  portable</span><span>
</span><span id="line-18"></span><span class="hs-comment">--</span><span>
</span><span id="line-19"></span><span class="hs-comment">-- The Dynamic interface provides basic support for dynamic types.</span><span>
</span><span id="line-20"></span><span class="hs-comment">--</span><span>
</span><span id="line-21"></span><span class="hs-comment">-- Operations for injecting values of arbitrary type into</span><span>
</span><span id="line-22"></span><span class="hs-comment">-- a dynamically typed value, Dynamic, are provided, together</span><span>
</span><span id="line-23"></span><span class="hs-comment">-- with operations for converting dynamic values into a concrete</span><span>
</span><span id="line-24"></span><span class="hs-comment">-- (monomorphic) type.</span><span>
</span><span id="line-25"></span><span class="hs-comment">--</span><span>
</span><span id="line-26"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-27"></span><span>
</span><span id="line-28"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Data.Dynamic</span><span>
</span><span id="line-29"></span><span>  </span><span class="hs-special">(</span><span>
</span><span id="line-30"></span><span>
</span><span id="line-31"></span><span>        </span><span class="annot"><span class="hs-comment">-- * The @Dynamic@ type</span></span><span>
</span><span id="line-32"></span><span>        </span><span class="annot"><a href="Data.Dynamic.html#Dynamic"><span class="hs-identifier">Dynamic</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-33"></span><span>
</span><span id="line-34"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Converting to and from @Dynamic@</span></span><span>
</span><span id="line-35"></span><span>        </span><span class="annot"><a href="Data.Dynamic.html#toDyn"><span class="hs-identifier">toDyn</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-36"></span><span>        </span><span class="annot"><a href="Data.Dynamic.html#fromDyn"><span class="hs-identifier">fromDyn</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-37"></span><span>        </span><span class="annot"><a href="Data.Dynamic.html#fromDynamic"><span class="hs-identifier">fromDynamic</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-38"></span><span>
</span><span id="line-39"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Applying functions of dynamic type</span></span><span>
</span><span id="line-40"></span><span>        </span><span class="annot"><a href="Data.Dynamic.html#dynApply"><span class="hs-identifier">dynApply</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-41"></span><span>        </span><span class="annot"><a href="Data.Dynamic.html#dynApp"><span class="hs-identifier">dynApp</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-42"></span><span>        </span><span class="annot"><a href="Data.Dynamic.html#dynTypeRep"><span class="hs-identifier">dynTypeRep</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-43"></span><span>
</span><span id="line-44"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Convenience re-exports</span></span><span>
</span><span id="line-45"></span><span>        </span><span class="annot"><a href="Data.Typeable.Internal.html#Typeable"><span class="hs-identifier">Typeable</span></a></span><span>
</span><span id="line-46"></span><span>
</span><span id="line-47"></span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-48"></span><span>
</span><span id="line-49"></span><span>
</span><span id="line-50"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Type.Equality.html"><span class="hs-identifier">Data.Type.Equality</span></a></span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Type.Reflection.html"><span class="hs-identifier">Type.Reflection</span></a></span><span>
</span><span id="line-52"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Maybe.html"><span class="hs-identifier">Data.Maybe</span></a></span><span>
</span><span id="line-53"></span><span>
</span><span id="line-54"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Base.html"><span class="hs-identifier">GHC.Base</span></a></span><span>
</span><span id="line-55"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Show.html"><span class="hs-identifier">GHC.Show</span></a></span><span>
</span><span id="line-56"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Exception.html"><span class="hs-identifier">GHC.Exception</span></a></span><span>
</span><span id="line-57"></span><span>
</span><span id="line-58"></span><span class="hs-comment">-------------------------------------------------------------</span><span>
</span><span id="line-59"></span><span class="hs-comment">--</span><span>
</span><span id="line-60"></span><span class="hs-comment">--              The type Dynamic</span><span>
</span><span id="line-61"></span><span class="hs-comment">--</span><span>
</span><span id="line-62"></span><span class="hs-comment">-------------------------------------------------------------</span><span>
</span><span id="line-63"></span><span>
</span><span id="line-64"></span><span class="hs-comment">{-|
  A value of type 'Dynamic' is an object encapsulated together with its type.

  A 'Dynamic' may only represent a monomorphic value; an attempt to
  create a value of type 'Dynamic' from a polymorphically-typed
  expression will result in an ambiguity error (see 'toDyn').

  'Show'ing a value of type 'Dynamic' returns a pretty-printed representation
  of the object\'s type; useful for debugging.
-}</span><span>
</span><span id="line-74"></span><span class="hs-keyword">data</span><span> </span><span id="Dynamic"><span class="annot"><a href="Data.Dynamic.html#Dynamic"><span class="hs-identifier hs-var">Dynamic</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-75"></span><span>    </span><span id="Dynamic"><span class="annot"><a href="Data.Dynamic.html#Dynamic"><span class="hs-identifier hs-var">Dynamic</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621679562811"><span class="annot"><a href="#local-6989586621679562811"><span class="hs-identifier hs-type">a</span></a></span></span><span class="hs-operator">.</span><span> </span><span class="annot"><a href="Data.Typeable.Internal.html#TypeRep"><span class="hs-identifier hs-type">TypeRep</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679562811"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679562811"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Dynamic.html#Dynamic"><span class="hs-identifier hs-type">Dynamic</span></a></span><span>
</span><span id="line-76"></span><span>
</span><span id="line-77"></span><span class="hs-comment">-- | @since 2.01</span><span>
</span><span id="line-78"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679562806"><span id="local-6989586621679562808"><span class="annot"><a href="GHC.Show.html#Show"><span class="hs-identifier hs-type">Show</span></a></span><span> </span><span class="annot"><a href="Data.Dynamic.html#Dynamic"><span class="hs-identifier hs-type">Dynamic</span></a></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-79"></span><span>   </span><span class="hs-comment">-- the instance just prints the type representation.</span><span>
</span><span id="line-80"></span><span>   </span><span id="local-6989586621679562804"><span class="annot"><span class="annottext">showsPrec :: Int -&gt; Dynamic -&gt; ShowS
</span><a href="GHC.Show.html#showsPrec"><span class="hs-identifier hs-var hs-var hs-var hs-var">showsPrec</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Dynamic.html#Dynamic"><span class="hs-identifier hs-type">Dynamic</span></a></span><span> </span><span id="local-6989586621679562800"><span class="annot"><span class="annottext">TypeRep a
</span><a href="#local-6989586621679562800"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span class="annot"><span class="annottext">a
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-81"></span><span>          </span><span class="annot"><span class="annottext">String -&gt; ShowS
</span><a href="GHC.Show.html#showString"><span class="hs-identifier hs-var">showString</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;&lt;&lt;&quot;</span></span><span> </span><span class="annot"><span class="annottext">ShowS -&gt; ShowS -&gt; ShowS
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span>
</span><span id="line-82"></span><span>          </span><span class="annot"><span class="annottext">Int -&gt; TypeRep a -&gt; ShowS
forall a. Show a =&gt; Int -&gt; a -&gt; ShowS
</span><a href="GHC.Show.html#showsPrec"><span class="hs-identifier hs-var">showsPrec</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">TypeRep a
</span><a href="#local-6989586621679562800"><span class="hs-identifier hs-var">t</span></a></span><span>   </span><span class="annot"><span class="annottext">ShowS -&gt; ShowS -&gt; ShowS
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span>
</span><span id="line-83"></span><span>          </span><span class="annot"><span class="annottext">String -&gt; ShowS
</span><a href="GHC.Show.html#showString"><span class="hs-identifier hs-var">showString</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;&gt;&gt;&quot;</span></span><span>
</span><span id="line-84"></span><span>
</span><span id="line-85"></span><span class="hs-comment">-- here so that it isn't an orphan:</span><span>
</span><span id="line-86"></span><span class="hs-comment">-- | @since 4.0.0.0</span><span>
</span><span id="line-87"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679562788"><span id="local-6989586621679562790"><span id="local-6989586621679562792"><span class="annot"><a href="GHC.Exception.Type.html#Exception"><span class="hs-identifier hs-type">Exception</span></a></span><span> </span><span class="annot"><a href="Data.Dynamic.html#Dynamic"><span class="hs-identifier hs-type">Dynamic</span></a></span></span></span></span><span>
</span><span id="line-88"></span><span>
</span><span id="line-89"></span><span> </span><span class="hs-comment">-- Use GHC's primitive 'Any' type to hold the dynamically typed value.</span><span>
</span><span id="line-90"></span><span> </span><span class="hs-comment">--</span><span>
</span><span id="line-91"></span><span> </span><span class="hs-comment">-- In GHC's new eval/apply execution model this type must not look</span><span>
</span><span id="line-92"></span><span> </span><span class="hs-comment">-- like a data type.  If it did, GHC would use the constructor convention</span><span>
</span><span id="line-93"></span><span> </span><span class="hs-comment">-- when evaluating it, and this will go wrong if the object is really a</span><span>
</span><span id="line-94"></span><span> </span><span class="hs-comment">-- function.  Using Any forces GHC to use</span><span>
</span><span id="line-95"></span><span> </span><span class="hs-comment">-- a fallback convention for evaluating it that works for all types.</span><span>
</span><span id="line-96"></span><span>
</span><span id="line-97"></span><span class="hs-comment">-- | Converts an arbitrary value into an object of type 'Dynamic'.</span><span>
</span><span id="line-98"></span><span class="hs-comment">--</span><span>
</span><span id="line-99"></span><span class="hs-comment">-- The type of the object must be an instance of 'Typeable', which</span><span>
</span><span id="line-100"></span><span class="hs-comment">-- ensures that only monomorphically-typed objects may be converted to</span><span>
</span><span id="line-101"></span><span class="hs-comment">-- 'Dynamic'.  To convert a polymorphic object into 'Dynamic', give it</span><span>
</span><span id="line-102"></span><span class="hs-comment">-- a monomorphic type signature.  For example:</span><span>
</span><span id="line-103"></span><span class="hs-comment">--</span><span>
</span><span id="line-104"></span><span class="hs-comment">-- &gt;    toDyn (id :: Int -&gt; Int)</span><span>
</span><span id="line-105"></span><span class="hs-comment">--</span><span>
</span><span id="line-106"></span><span id="local-6989586621679562858"><span class="annot"><a href="Data.Dynamic.html#toDyn"><span class="hs-identifier hs-type">toDyn</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.Typeable.Internal.html#Typeable"><span class="hs-identifier hs-type">Typeable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679562858"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679562858"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Dynamic.html#Dynamic"><span class="hs-identifier hs-type">Dynamic</span></a></span></span><span>
</span><span id="line-107"></span><span id="toDyn"><span class="annot"><span class="annottext">toDyn :: forall a. Typeable a =&gt; a -&gt; Dynamic
</span><a href="Data.Dynamic.html#toDyn"><span class="hs-identifier hs-var hs-var">toDyn</span></a></span></span><span> </span><span id="local-6989586621679562784"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679562784"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TypeRep a -&gt; a -&gt; Dynamic
forall a. TypeRep a -&gt; a -&gt; Dynamic
</span><a href="Data.Dynamic.html#Dynamic"><span class="hs-identifier hs-var">Dynamic</span></a></span><span> </span><span class="annot"><span class="annottext">TypeRep a
forall {k} (a :: k). Typeable a =&gt; TypeRep a
</span><a href="Data.Typeable.Internal.html#typeRep"><span class="hs-identifier hs-var">typeRep</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679562784"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-108"></span><span>
</span><span id="line-109"></span><span class="hs-comment">-- | Converts a 'Dynamic' object back into an ordinary Haskell value of</span><span>
</span><span id="line-110"></span><span class="hs-comment">-- the correct type.  See also 'fromDynamic'.</span><span>
</span><span id="line-111"></span><span id="local-6989586621679562853"><span class="annot"><a href="Data.Dynamic.html#fromDyn"><span class="hs-identifier hs-type">fromDyn</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.Typeable.Internal.html#Typeable"><span class="hs-identifier hs-type">Typeable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679562853"><span class="hs-identifier hs-type">a</span></a></span><span>
</span><span id="line-112"></span><span>        </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="Data.Dynamic.html#Dynamic"><span class="hs-identifier hs-type">Dynamic</span></a></span><span>      </span><span class="hs-comment">-- ^ the dynamically-typed object</span><span>
</span><span id="line-113"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679562853"><span class="hs-identifier hs-type">a</span></a></span><span>            </span><span class="hs-comment">-- ^ a default value</span><span>
</span><span id="line-114"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679562853"><span class="hs-identifier hs-type">a</span></a></span></span><span>            </span><span class="hs-comment">-- ^ returns: the value of the first argument, if</span><span>
</span><span id="line-115"></span><span>                        </span><span class="hs-comment">-- it has the correct type, otherwise the value of</span><span>
</span><span id="line-116"></span><span>                        </span><span class="hs-comment">-- the second argument.</span><span>
</span><span id="line-117"></span><span id="fromDyn"><span class="annot"><span class="annottext">fromDyn :: forall a. Typeable a =&gt; Dynamic -&gt; a -&gt; a
</span><a href="Data.Dynamic.html#fromDyn"><span class="hs-identifier hs-var hs-var">fromDyn</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Dynamic.html#Dynamic"><span class="hs-identifier hs-type">Dynamic</span></a></span><span> </span><span id="local-6989586621679562780"><span class="annot"><span class="annottext">TypeRep a
</span><a href="#local-6989586621679562780"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span id="local-6989586621679562779"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679562779"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679562778"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679562778"><span class="hs-identifier hs-var">def</span></a></span></span><span>
</span><span id="line-118"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="annot"><span class="annottext">a :~~: a
</span><a href="Data.Type.Equality.html#HRefl"><span class="hs-identifier hs-var">HRefl</span></a></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TypeRep a
</span><a href="#local-6989586621679562780"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="annot"><span class="annottext">TypeRep a -&gt; TypeRep a -&gt; Maybe (a :~~: a)
forall k1 k2 (a :: k1) (b :: k2).
TypeRep a -&gt; TypeRep b -&gt; Maybe (a :~~: b)
</span><a href="Data.Typeable.Internal.html#eqTypeRep"><span class="hs-operator hs-var">`eqTypeRep`</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; TypeRep a
forall a. Typeable a =&gt; a -&gt; TypeRep a
</span><a href="Data.Typeable.Internal.html#typeOf"><span class="hs-identifier hs-var">typeOf</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679562778"><span class="hs-identifier hs-var">def</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a
a
</span><a href="#local-6989586621679562779"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-119"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679562778"><span class="hs-identifier hs-var">def</span></a></span><span>
</span><span id="line-120"></span><span>
</span><span id="line-121"></span><span class="hs-comment">-- | Converts a 'Dynamic' object back into an ordinary Haskell value of</span><span>
</span><span id="line-122"></span><span class="hs-comment">-- the correct type.  See also 'fromDyn'.</span><span>
</span><span id="line-123"></span><span class="annot"><a href="Data.Dynamic.html#fromDynamic"><span class="hs-identifier hs-type">fromDynamic</span></a></span><span>
</span><span id="line-124"></span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621679562844"><span class="annot"><a href="#local-6989586621679562844"><span class="hs-identifier hs-type">a</span></a></span></span><span class="hs-operator">.</span><span> </span><span class="annot"><a href="Data.Typeable.Internal.html#Typeable"><span class="hs-identifier hs-type">Typeable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679562844"><span class="hs-identifier hs-type">a</span></a></span><span>
</span><span id="line-125"></span><span>        </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="Data.Dynamic.html#Dynamic"><span class="hs-identifier hs-type">Dynamic</span></a></span><span>      </span><span class="hs-comment">-- ^ the dynamically-typed object</span><span>
</span><span id="line-126"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679562844"><span class="hs-identifier hs-type">a</span></a></span><span>      </span><span class="hs-comment">-- ^ returns: @'Just' a@, if the dynamically-typed</span><span>
</span><span id="line-127"></span><span>                        </span><span class="hs-comment">-- object has the correct type (and @a@ is its value),</span><span>
</span><span id="line-128"></span><span>                        </span><span class="hs-comment">-- or 'Nothing' otherwise.</span><span>
</span><span id="line-129"></span><span id="fromDynamic"><span class="annot"><span class="annottext">fromDynamic :: forall a. Typeable a =&gt; Dynamic -&gt; Maybe a
</span><a href="Data.Dynamic.html#fromDynamic"><span class="hs-identifier hs-var hs-var">fromDynamic</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Dynamic.html#Dynamic"><span class="hs-identifier hs-type">Dynamic</span></a></span><span> </span><span id="local-6989586621679562769"><span class="annot"><span class="annottext">TypeRep a
</span><a href="#local-6989586621679562769"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span id="local-6989586621679562768"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679562768"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-130"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="annot"><span class="annottext">a :~~: a
</span><a href="Data.Type.Equality.html#HRefl"><span class="hs-identifier hs-var">HRefl</span></a></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TypeRep a
</span><a href="#local-6989586621679562769"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="annot"><span class="annottext">TypeRep a -&gt; TypeRep a -&gt; Maybe (a :~~: a)
forall k1 k2 (a :: k1) (b :: k2).
TypeRep a -&gt; TypeRep b -&gt; Maybe (a :~~: b)
</span><a href="Data.Typeable.Internal.html#eqTypeRep"><span class="hs-operator hs-var">`eqTypeRep`</span></a></span><span> </span><span class="annot"><span class="annottext">TypeRep a
</span><a href="#local-6989586621679562764"><span class="hs-identifier hs-var">rep</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a -&gt; Maybe a
forall a. a -&gt; Maybe a
</span><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679562768"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-131"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe a
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-132"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621679562764"><span class="annot"><span class="annottext">rep :: TypeRep a
</span><a href="#local-6989586621679562764"><span class="hs-identifier hs-var hs-var">rep</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TypeRep a
forall {k} (a :: k). Typeable a =&gt; TypeRep a
</span><a href="Data.Typeable.Internal.html#typeRep"><span class="hs-identifier hs-var">typeRep</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.Typeable.Internal.html#TypeRep"><span class="hs-identifier hs-type">TypeRep</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679562844"><span class="hs-identifier hs-type">a</span></a></span><span>
</span><span id="line-133"></span><span>
</span><span id="line-134"></span><span class="hs-comment">-- (f::(a-&gt;b)) `dynApply` (x::a) = (f a)::b</span><span>
</span><span id="line-135"></span><span class="annot"><a href="Data.Dynamic.html#dynApply"><span class="hs-identifier hs-type">dynApply</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.Dynamic.html#Dynamic"><span class="hs-identifier hs-type">Dynamic</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Dynamic.html#Dynamic"><span class="hs-identifier hs-type">Dynamic</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="Data.Dynamic.html#Dynamic"><span class="hs-identifier hs-type">Dynamic</span></a></span><span>
</span><span id="line-136"></span><span id="dynApply"><span class="annot"><span class="annottext">dynApply :: Dynamic -&gt; Dynamic -&gt; Maybe Dynamic
</span><a href="Data.Dynamic.html#dynApply"><span class="hs-identifier hs-var hs-var">dynApply</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Dynamic.html#Dynamic"><span class="hs-identifier hs-type">Dynamic</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Typeable.Internal.html#Fun"><span class="hs-identifier hs-type">Fun</span></a></span><span> </span><span id="local-6989586621679562759"><span class="annot"><span class="annottext">TypeRep arg
</span><a href="#local-6989586621679562759"><span class="hs-identifier hs-var">ta</span></a></span></span><span> </span><span id="local-6989586621679562758"><span class="annot"><span class="annottext">TypeRep res
</span><a href="#local-6989586621679562758"><span class="hs-identifier hs-var">tr</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679562757"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679562757"><span class="hs-identifier hs-var">f</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Dynamic.html#Dynamic"><span class="hs-identifier hs-type">Dynamic</span></a></span><span> </span><span id="local-6989586621679562756"><span class="annot"><span class="annottext">TypeRep a
</span><a href="#local-6989586621679562756"><span class="hs-identifier hs-var">ta'</span></a></span></span><span> </span><span id="local-6989586621679562755"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679562755"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-137"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="annot"><span class="annottext">arg :~~: a
</span><a href="Data.Type.Equality.html#HRefl"><span class="hs-identifier hs-var">HRefl</span></a></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TypeRep arg
</span><a href="#local-6989586621679562759"><span class="hs-identifier hs-var">ta</span></a></span><span> </span><span class="annot"><span class="annottext">TypeRep arg -&gt; TypeRep a -&gt; Maybe (arg :~~: a)
forall k1 k2 (a :: k1) (b :: k2).
TypeRep a -&gt; TypeRep b -&gt; Maybe (a :~~: b)
</span><a href="Data.Typeable.Internal.html#eqTypeRep"><span class="hs-operator hs-var">`eqTypeRep`</span></a></span><span> </span><span class="annot"><span class="annottext">TypeRep a
</span><a href="#local-6989586621679562756"><span class="hs-identifier hs-var">ta'</span></a></span><span>
</span><span id="line-138"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="annot"><span class="annottext">* :~~: TYPE r2
</span><a href="Data.Type.Equality.html#HRefl"><span class="hs-identifier hs-var">HRefl</span></a></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">forall a. Typeable a =&gt; TypeRep a
forall {k} (a :: k). Typeable a =&gt; TypeRep a
</span><a href="Data.Typeable.Internal.html#typeRep"><span class="hs-identifier hs-var">typeRep</span></a></span><span> </span><span class="hs-glyph">@</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="annot"><span class="annottext">TypeRep (*) -&gt; TypeRep (TYPE r2) -&gt; Maybe (* :~~: TYPE r2)
forall k1 k2 (a :: k1) (b :: k2).
TypeRep a -&gt; TypeRep b -&gt; Maybe (a :~~: b)
</span><a href="Data.Typeable.Internal.html#eqTypeRep"><span class="hs-operator hs-var">`eqTypeRep`</span></a></span><span> </span><span class="annot"><span class="annottext">TypeRep res -&gt; TypeRep (TYPE r2)
forall k (a :: k). TypeRep a -&gt; TypeRep k
</span><a href="Data.Typeable.Internal.html#typeRepKind"><span class="hs-identifier hs-var">typeRepKind</span></a></span><span> </span><span class="annot"><span class="annottext">TypeRep res
</span><a href="#local-6989586621679562758"><span class="hs-identifier hs-var">tr</span></a></span><span>
</span><span id="line-139"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Dynamic -&gt; Maybe Dynamic
forall a. a -&gt; Maybe a
</span><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TypeRep res -&gt; res -&gt; Dynamic
forall a. TypeRep a -&gt; a -&gt; Dynamic
</span><a href="Data.Dynamic.html#Dynamic"><span class="hs-identifier hs-var">Dynamic</span></a></span><span> </span><span class="annot"><span class="annottext">TypeRep res
TypeRep res
</span><a href="#local-6989586621679562758"><span class="hs-identifier hs-var">tr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
a -&gt; res
</span><a href="#local-6989586621679562757"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679562755"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-140"></span><span class="annot"><a href="Data.Dynamic.html#dynApply"><span class="hs-identifier hs-var">dynApply</span></a></span><span> </span><span class="annot"><span class="annottext">Dynamic
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Dynamic
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-141"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe Dynamic
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-142"></span><span>
</span><span id="line-143"></span><span class="annot"><a href="Data.Dynamic.html#dynApp"><span class="hs-identifier hs-type">dynApp</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.Dynamic.html#Dynamic"><span class="hs-identifier hs-type">Dynamic</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Dynamic.html#Dynamic"><span class="hs-identifier hs-type">Dynamic</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Dynamic.html#Dynamic"><span class="hs-identifier hs-type">Dynamic</span></a></span><span>
</span><span id="line-144"></span><span id="dynApp"><span class="annot"><span class="annottext">dynApp :: Dynamic -&gt; Dynamic -&gt; Dynamic
</span><a href="Data.Dynamic.html#dynApp"><span class="hs-identifier hs-var hs-var">dynApp</span></a></span></span><span> </span><span id="local-6989586621679562741"><span class="annot"><span class="annottext">Dynamic
</span><a href="#local-6989586621679562741"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621679562740"><span class="annot"><span class="annottext">Dynamic
</span><a href="#local-6989586621679562740"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Dynamic -&gt; Dynamic -&gt; Maybe Dynamic
</span><a href="Data.Dynamic.html#dynApply"><span class="hs-identifier hs-var">dynApply</span></a></span><span> </span><span class="annot"><span class="annottext">Dynamic
</span><a href="#local-6989586621679562741"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">Dynamic
</span><a href="#local-6989586621679562740"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-145"></span><span>             </span><span class="annot"><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679562739"><span class="annot"><span class="annottext">Dynamic
</span><a href="#local-6989586621679562739"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Dynamic
</span><a href="#local-6989586621679562739"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-146"></span><span>             </span><span class="annot"><span class="annottext">Maybe Dynamic
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; Dynamic
forall a. String -&gt; a
</span><a href="GHC.Err.html#errorWithoutStackTrace"><span class="hs-identifier hs-var">errorWithoutStackTrace</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Type error in dynamic application.\n&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; ShowS
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span>
</span><span id="line-147"></span><span>                               </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Can't apply function &quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; ShowS
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">Dynamic -&gt; String
forall a. Show a =&gt; a -&gt; String
</span><a href="GHC.Show.html#show"><span class="hs-identifier hs-var">show</span></a></span><span> </span><span class="annot"><span class="annottext">Dynamic
</span><a href="#local-6989586621679562741"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; ShowS
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span>
</span><span id="line-148"></span><span>                               </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot; to argument &quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; ShowS
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">Dynamic -&gt; String
forall a. Show a =&gt; a -&gt; String
</span><a href="GHC.Show.html#show"><span class="hs-identifier hs-var">show</span></a></span><span> </span><span class="annot"><span class="annottext">Dynamic
</span><a href="#local-6989586621679562740"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-149"></span><span>
</span><span id="line-150"></span><span class="annot"><a href="Data.Dynamic.html#dynTypeRep"><span class="hs-identifier hs-type">dynTypeRep</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.Dynamic.html#Dynamic"><span class="hs-identifier hs-type">Dynamic</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Typeable.Internal.html#SomeTypeRep"><span class="hs-identifier hs-type">SomeTypeRep</span></a></span><span>
</span><span id="line-151"></span><span id="dynTypeRep"><span class="annot"><span class="annottext">dynTypeRep :: Dynamic -&gt; SomeTypeRep
</span><a href="Data.Dynamic.html#dynTypeRep"><span class="hs-identifier hs-var hs-var">dynTypeRep</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Dynamic.html#Dynamic"><span class="hs-identifier hs-type">Dynamic</span></a></span><span> </span><span id="local-6989586621679562736"><span class="annot"><span class="annottext">TypeRep a
</span><a href="#local-6989586621679562736"><span class="hs-identifier hs-var">tr</span></a></span></span><span> </span><span class="annot"><span class="annottext">a
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TypeRep a -&gt; SomeTypeRep
forall k (a :: k). TypeRep a -&gt; SomeTypeRep
</span><a href="Data.Typeable.Internal.html#SomeTypeRep"><span class="hs-identifier hs-var">SomeTypeRep</span></a></span><span> </span><span class="annot"><span class="annottext">TypeRep a
</span><a href="#local-6989586621679562736"><span class="hs-identifier hs-var">tr</span></a></span><span>
</span><span id="line-152"></span></pre></body></html>